<?php 
include('./include/conn.php');
$query = 'SELECT `id`,`title` FROM msg ORDER BY time DESC';
$rs = $link->query($query);
include('./include/header.php');
?>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<article>
		<?php
		 
			//只有当用户登录成功才显示    添加话题、删除话题  功能
			if (isset($_SESSION['u'])) {
				echo "<p><a href='add.php'>添加话题</a><a href='#'>删除话题</a></p>";
			}
			if($rs->num_rows){
				 /*
				if(isset($_SESSION['u'])){
	    		echo "<p><a href='add.php'>添加话题</a><a href='#'>删除话题</a></p>"
				}
				 */	
				echo '<div class="title"><storong>讨论话题</storong></div>';
				while ($row = $rs->fetch_assoc()) {
					echo '<p>'.$row['title'].'<span><a href=desc.php?id='.$row['id'].'>进入话题</a></span></p>';
				}
			}else{
				/*
				if(isset($_SESSION['u'])){
				  echo"<p><a href='add.php'>添加话题</a><a href='del.php'>删除话题</a></p>";
				  echo "<p class='null_data'>暂无话题！请添加话题。</p>";
				}else{*/
					echo "<p class='null_data'>暂无话题！只有注册用户可添加话题。</p>";
					//}
			}
		?>
	</article>
</body>
</html>